#!/bin/bash
read -p "请输入网址：" internet
read -p "请输入网页保存路径：" tmp_html
read -p "请输入链接保存路径：" www_link
#wget -r -p -O ${tmp_html} ${internet} &> /etc/null
curl -L -o ${tmp_html} ${internet} &> /etc/null
echo OK

#cat ${tmp_html} | awk -F "=" '{print $2}' | awk -F ">" '{print $1}' | awk /^\"/ | awk -F "\"" '{print $2}' | awk /^http/ > ${www_link}
#  能统计任意http地址，但存在获取不全
<<comment
cat ${tmp_html} | tr '\n' "," | awk -F "\"" '{for(i=1;i<=NF;i++) \
    a[i,NR]=$i}END{for(i=1;i<=NF;i++) {for(j=1;j<=NR;j++) \
        printf "%s", a[i,j]; print " "}}' | tee ${tmp_html} &> /dev/null

if test $? == 0;then
    awk /^http/ ${tmp_html} > ${www_link}
    echo “连接获取成功，已保存至${www_link}”
fi
comment
# 只能统计a标签地址
cat ${tmp_html}  | tr " " "\n" | awk -F "\"" '{print $2}' | tee ${www_link} &>/dev/null
if test $? == 0;then
   awk /^http/ ${www_link} > www_link
   echo "链接获取成功，已保存至www_link"
fi
